/*
 * Copyright (c) 2025 Industrial Software Feature Database
 */
package com.comac.ins.isfd.constant.enums;

import com.comac.ins.common.core.utils.StringUtils;
import lombok.AllArgsConstructor;
import lombok.Getter;

/**
 * 算法配置类型
 *
 * @author hxloongs
 * @date 2025-5-12
 */
@AllArgsConstructor
@Getter
public enum IsfdAlgorithmConfigTypeEnum {
    SECTION("section", "型材类型算法");
    private final String value;
    private final String desc;

    public static String getDescByValue(String value) {
        IsfdAlgorithmConfigTypeEnum isfdAlgorithmConfigTypeEnum = forValue(value);
        if (isfdAlgorithmConfigTypeEnum == null) {
            return null;
        }
        return isfdAlgorithmConfigTypeEnum.getDesc();
    }

    public static IsfdAlgorithmConfigTypeEnum forValue(String value) {
        if (StringUtils.isBlank(value)) {
            return null;
        }
        for (IsfdAlgorithmConfigTypeEnum isfdAlgorithmConfigTypeEnum : IsfdAlgorithmConfigTypeEnum.values()) {
            if (isfdAlgorithmConfigTypeEnum.getValue().equals(value)) {
                return isfdAlgorithmConfigTypeEnum;
            }
        }
        return null;
    }

    public static IsfdAlgorithmConfigTypeEnum forDesc(String desc) {
        if (desc == null) {
            return null;
        }
        for (IsfdAlgorithmConfigTypeEnum isfdAlgorithmConfigTypeEnum : IsfdAlgorithmConfigTypeEnum.values()) {
            if (desc.equals(isfdAlgorithmConfigTypeEnum.getDesc())) {
                return isfdAlgorithmConfigTypeEnum;
            }
        }
        return null;
    }
}
